<?php

class YongjinModel extends Model {
	
	public function get_primary_key() {
		return $this->primary_key = 'id';
	}
	public function get_paisong_list(){
		
	}

	public function set($id, $data) {
	//	$data['site'] = App::get_site_id();
	    if ($id) {
	        $this->update($data, 'id=' . $id);
	        return $id;
	    }
	    $this->insert($data);
	    if ($this->get_insert_id()) return $this->get_insert_id();
	    return false;
	}
	
	
	//前台用
	function get_all_list($where,$order,$limit,$ifcount=false){
		if($ifcount){
			$sql = "select count(j.id) as total from ".$this->prefix . "member_yongjin j"." 
			        left join ".$this->prefix ."member m on j.member_id=m.id "."
					where $where";
			$res = $this->db->query($sql)->row_array();
			return $res['total'];
		}
		$sql = "select j.*,m.name as mname from ".$this->prefix . "member_yongjin j"."
                left join ".$this->prefix ."member m on j.member_id=m.id "."
		        where $where order by $order limit $limit";
		$res = $this->db->query($sql)->result_array();
		return $res;
	}
	
	


}